package com.msmall.community.growcycle.action.html;

import com.msmall.base.action.BaseAction;
import com.msmall.base.cache.CacheFactory;
import com.msmall.base.util.ConstantDB;
import com.msmall.base.util.Constants;
import com.msmall.community.common.CascadeCollection;
import com.msmall.community.dpt.model.Segment;
import com.msmall.community.growcycle.vo.Growcycle;

public class GrowcycleAction extends BaseAction{

	private static final long serialVersionUID = -2098930876527606144L;
	
	private Long segid;
	
	private Growcycle growcycle;
	
	private CascadeCollection<Segment> current;
	
	public String view(){
		CascadeCollection<Segment> cs = (CascadeCollection<Segment>) CacheFactory.getInstance().getCache(Constants.CACHE_NAME_COMMON).get(Constants.CACHE_KEY_SEGMENT_CASCADECOLLECTION);
		current = cs.getAllDatas().get(segid);
		CascadeCollection<Segment> parent = current.getParents().get(0);
		growcycle = new Growcycle();
		String fileName = "";
		if(ConstantDB.SEGMENT_ID_TIMELINE_NAV.compareTo(parent.getCurrent().getSegmentid()) == 0){
			fileName = current.getCurrent().getSegmentid() + Constants.FILE_HTML_EXTENDS;
		}else{
			fileName = parent.getCurrent().getSegmentid() + "-" + current.getCurrent().getSegmentid() + Constants.FILE_HTML_EXTENDS;
		}
		growcycle.setFileName(fileName);
		return SUCCESS;
	}

	public Long getSegid() {
		return segid;
	}

	public void setSegid(Long segid) {
		this.segid = segid;
	}

	public Growcycle getGrowcycle() {
		return growcycle;
	}

	public void setGrowcycle(Growcycle growcycle) {
		this.growcycle = growcycle;
	}

	public CascadeCollection<Segment> getCurrent() {
		return current;
	}

	public void setCurrent(CascadeCollection<Segment> current) {
		this.current = current;
	}

}
